package com.jinxin.platform.cdelecinspect.controller;

import com.jinxin.platform.cdelecinspect.mapper.pojo.CdelecinspectStatistics;
import com.jinxin.platform.cdelecinspect.service.CdelecinspectStatisticsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/insStatistics")
public class CdelecinspectStatisticsController {

    @Autowired
    private CdelecinspectStatisticsService cdelecinspectStatisticsService;

    /**
     * 查询所有记录
     *
     * @return 返回集合，没有返回空List
     */
    @RequestMapping("list")
    public Map<String,Object> listByCondition(String staffId, String startTime, String endTime,
    @RequestParam long page, @RequestParam long limit) {
        Map<String,Object> resultMap = new HashMap<>();
        HashMap param = new HashMap<>();
        param.put("staffId",staffId);
        param.put("startDate",startTime);
        param.put("endDate",endTime);
        param.put("page", page);
        param.put("limit", limit);
        resultMap.put("code",0);
        resultMap.put("msg","");
        resultMap.put("count",cdelecinspectStatisticsService.listCount(param));
        resultMap.put("data",cdelecinspectStatisticsService.listPage(param));
        return resultMap;
    }


    /**
     * 根据主键查询
     *
     * @param id 主键
     * @return 返回记录，没有返回null
     */
    @RequestMapping("getById")
    public CdelecinspectStatistics getById(String id) {
        return cdelecinspectStatisticsService.getById(id);
    }    
     
    /**
     * 新增，忽略null字段
     *
     * @param cdelecinspectStatistics 新增的记录
     * @return 返回影响行数
     */
    @RequestMapping("insert")
    public int insert(@RequestBody CdelecinspectStatistics cdelecinspectStatistics) {
        return cdelecinspectStatisticsService.insertIgnoreNull(cdelecinspectStatistics);
    }    
      
    /**
     * 修改，忽略null字段
     *
     * @param cdelecinspectStatistics 修改的记录
     * @return 返回影响行数
     */
    @RequestMapping("update")
    public int update(@RequestBody CdelecinspectStatistics cdelecinspectStatistics) {
        return cdelecinspectStatisticsService.updateIgnoreNull(cdelecinspectStatistics);
    }
    
    /**
     * 删除记录
     *
     * @param cdelecinspectStatistics 待删除的记录
     * @return 返回影响行数
     */
    @RequestMapping("delete")
    public int delete(@RequestBody CdelecinspectStatistics cdelecinspectStatistics) {
        return cdelecinspectStatisticsService.delete(cdelecinspectStatistics);
    }
    
}